package com.itstudy.moonapimemberserviceimpl.controller;

import com.itstudy.moonapimemberservice.entity.UserEntity;
import com.itstudy.moonapimemberservice.service.IMemberService;
import com.itstudy.mooncommon.baseresponse.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * 相当于每个Controller都要向上抽取接口形成接口集合给别人调用
 * 而不是在feign调用的时候在客户端重复写接口代码
 * @author xianpengcheng@aliyun.com
 * @create 2019-04-12 16:27
 */
@RestController
@RequestMapping("/memberService")
@RefreshScope//在需要刷新的Bean上添加@RefreshScope注解。以便于手动刷新生效,一定要post执行:http://ip:port/actuator/refresh
public class MemberServiceController  implements IMemberService {

    @Value("${server.port}")
    private  String port;

    /**
     * 读取配置中心,没有读到就取默认值
     */
    @Value("${foo:foodefault}")
    private  String foo;



    @RequestMapping("/getUserInfo")
    public R getUserInfo(@RequestParam("name") String name, @RequestParam("age")Integer age) {
        System.out.println("MemberServiceController端口---port-------->"+port);
        UserEntity userEntity = new UserEntity();
        userEntity.setName(name);
        userEntity.setAge(age);
        userEntity.setRemark(foo);
        return R.ok().put("userEntity", userEntity);
    }

}
